package com.taotao.springboot2.warmflow;


import org.dromara.warm.flow.core.FlowFactory;
import org.dromara.warm.flow.core.entity.Definition;
import org.dromara.warm.flow.core.service.DefService;
import org.dromara.warm.flow.core.utils.page.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;


@Controller
@RequestMapping("/")
public class WarmflowPageController {

    @Resource
    private DefService defService;

    @GetMapping("/index")
    public ModelAndView index() {
        ModelAndView mav = new ModelAndView("/index");



        Definition flowDefinition = FlowFactory.newDef();
        Page<Definition> page = Page.pageOf(1, 1000000);
        page = defService.orderByCreateTime().desc().page(flowDefinition, page);
        List<Definition> list = page.getList();
        if(null != list){
            mav.addObject("defList",list);
        }



        return mav;
    }

}
